package com.ymttest.database.sqlwapper.sqdistributor;

import java.util.HashMap;
import java.util.List;

import com.ymt.database.SqlManager;
import com.ymttest.database.model.sqdistributor.ProductCommissionRate;

public class ProductCommissionRateWrapper {
	
	SqlManager manager;

	public ProductCommissionRateWrapper() {
		manager = new SqlManager("sqdistributor");
	}

	@SuppressWarnings("unchecked")
	public ProductCommissionRate selectByPrimaryKey(Long id) {

		ProductCommissionRate productCommissionRate = null;
		List<ProductCommissionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.ProductCommissionRateMapper.selectByPrimaryKey",
						id);
		manager.commit();

		if (result.size() > 0) {
			productCommissionRate = result.get(0);
		}

		return productCommissionRate;
	}
	
	@SuppressWarnings("unchecked")
	public ProductCommissionRate selectByConfigIdAndTypeAndLevel(Long configId, Integer type, Integer level) {

		HashMap<String, Object> map = new HashMap<>();
		
		map.put("product_commission_config_id", configId);
		map.put("commission_type", type);
		map.put("commission_level_index", level);
		
		ProductCommissionRate productCommissionRate = null;
		List<ProductCommissionRate> result = manager
				.getSelectResults(
						"com.ymttest.database.mapping.sqdistributor.ProductCommissionRateMapper.selectByConfigIdAndTypeAndLevel",
						map);
		manager.commit();

		if (result.size() > 0) {
			productCommissionRate = result.get(0);
		}

		return productCommissionRate;
	}
	
	public static void main(String[] args) {
		
		ProductCommissionRateWrapper test = new ProductCommissionRateWrapper();
		
//		SellerLevelHistory sellerLevelHistory = new SellerLevelHistory();
//		
//		sellerLevelHistory.setDDate(YMTDateUtil.getDate());
//		sellerLevelHistory.setSellerID(24635724);
//		sellerLevelHistory.setUpdateTime(YMTDateUtil.getDate());
//		sellerLevelHistory.setUnconfirm_amount(BigDecimal.TEN);
//		
		System.out.println(test.selectByConfigIdAndTypeAndLevel(9L, 1, 2).getLayer1_rate());
	}
}
